package com.itheima.demo9_多态的应用场景.返回值多态_2;

public class Test {
    public static void main(String[] args) {
        Animal anl1 = method("Dog");
        anl1.eat();
        Animal anl2 = method("Cat");
        anl2.eat();

    }

    public static Animal method(String classType) {
        if ("Dog".equals(classType)) {
            return new Dog();
        } else if ("Cat".equals(classType)) {
            return new Cat();
        } else if ("Animal".equals(classType)) {
            return new Animal();
        } else {
            return null;
        }
    }
}